﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.Composite.Events;

namespace FamilyShowSource.Events
{
    /// <summary>
    /// The class implements a publish/subscribe event mechanism
    /// </summary>
    public class EventAggregatorFactory
    {
        /// <summary>
        /// The singleton instance of the EventAggregator service
        /// </summary>
        private static EventAggregator _instance = null;

        /// <summary>
        /// Lock (sync) object
        /// </summary>
        private static readonly object _syncLock = new object();

        /// <summary>
        /// The property of the instance of the EventAggregator service
        /// </summary>
        public static EventAggregator Instance
        {
            get
            {
                // Lock execution thread in case of multi-threaded (concurrent) access.
                lock (_syncLock)
                {
                    if (_instance == null)
                        _instance = new EventAggregator();
                    return _instance;
                }
            }   
        }
    }
}
